Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(composer): interact with executor through handle #834

Merged
merged 3 commits into from
Mar 20, 2024

Conversation

bharath-123
Copy link
Contributor

@bharath-123 bharath-123 commented Mar 19, 2024

Summary

This is a minor refactor PR which moves the creation of the channel through which executor receives SequenceActions to submit to the Shared Sequence N/w to the executor.

Background

Previously, the channels were created by the Composer which creates the Executor. It is better practice to allow the Executor to create the channel which it owns and just return the sending end of it back to the Composer.

Changes

  • Create a struct Handle in Executor which is referenced as executor::Handle.
  • Handle creation of the executor::Handle in Executor and allow Executor to pass it back.

Testing

Since this is not a functional PR change, making sure that the code compiles and the tests run is enough to ensure that this works.

Note

The tests were initially using just send on the channel but the executor uses send_with_timeout. We could add just a send method to the executor::Handle. But to avoid clippy errors w.r.t unused method send and avoiding a #[cfg(test)] in the method, I updated the tests to use send_with_timeout instead of send.

closes

@github-actions github-actions bot added the composer pertaining to composer label Mar 19, 2024
@bharath-123 bharath-123 changed the title chore(composer): Move executor sequence action tx channel creation to executor chore(composer): Move executor sequence action transaction channel creation to executor Mar 19, 2024
@bharath-123 bharath-123 changed the title chore(composer): Move executor sequence action transaction channel creation to executor chore(composer): Move sequence action transaction channel creation to executor Mar 19, 2024
@bharath-123 bharath-123 marked this pull request as ready for review March 19, 2024 05:25
@bharath-123 bharath-123 force-pushed the bharath/executor-creates-handles branch from 650bf69 to f27fc69 Compare March 19, 2024 15:03
@bharath-123 bharath-123 changed the title chore(composer): Move sequence action transaction channel creation to executor chore(composer): Move executor channel creation to executor Mar 19, 2024
@bharath-123 bharath-123 force-pushed the bharath/executor-creates-handles branch 4 times, most recently from ec91a39 to 6a053e9 Compare March 19, 2024 16:59
@bharath-123 bharath-123 force-pushed the bharath/executor-creates-handles branch from 6a053e9 to bbf53b7 Compare March 20, 2024 06:43
Copy link
Member

@SuperFluffy SuperFluffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and is ready to merge after addressing the privacy issue around executor::Handle - it doesn't make sense allowing the construction of a handle to a thing that does not exist.

}

impl Handle {
pub(super) fn new(serialized_rollup_transactions_tx: mpsc::Sender<SequenceAction>) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor should not be pub(super) - it should only be callable from inside this module

(Very minor nit: I don't think this needs an explicit constructor - just create the handle in Executor::new (or however it's constructor is called).)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think thats a good point. i ll try just creating it in the Executor::new

}
}

pub(super) async fn send_with_timeout(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like the thin wrapper - but IMO just call this send_timeout.

@@ -89,7 +90,7 @@ pub(super) struct Executor {
// The status of this executor
status: watch::Sender<Status>,
// Channel for receiving `SequenceAction`s to be bundled.
serialized_rollup_transactions_rx: mpsc::Receiver<SequenceAction>,
sequence_action_rx: mpsc::Receiver<SequenceAction>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I'd just call this sequence_actions or new_sequence_actions. The _rx` doesn't add anything of substance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ll call it serialized_rollup_transactions just to keep the naming consistent.

@SuperFluffy SuperFluffy changed the title chore(composer): Move executor channel creation to executor refactor(composer): Move executor channel creation to executor Mar 20, 2024
@SuperFluffy SuperFluffy changed the title refactor(composer): Move executor channel creation to executor refactor(composer): interact with executor through handle Mar 20, 2024
@bharath-123 bharath-123 force-pushed the bharath/executor-creates-handles branch 8 times, most recently from aa22f69 to a3a06a8 Compare March 20, 2024 13:12
@@ -238,11 +238,11 @@ impl Geth {
/// # Errors
///
/// Returns the same error as tokio's [`Sender::send`].
pub fn abort(&self) -> Result<usize, SendError<SubscriptionCommand>> {
pub fn cancel_subscriptions(&self) -> Result<usize, SendError<SubscriptionCommand>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is more descriptive. I was confused by abort.

@bharath-123 bharath-123 force-pushed the bharath/executor-creates-handles branch from a3a06a8 to 8e0da40 Compare March 20, 2024 13:18
@bharath-123 bharath-123 force-pushed the bharath/executor-creates-handles branch 5 times, most recently from 20f99e6 to d7ee826 Compare March 20, 2024 15:07
@bharath-123 bharath-123 force-pushed the bharath/executor-creates-handles branch from d7ee826 to 7e225cb Compare March 20, 2024 15:08
@bharath-123 bharath-123 merged commit 87c49dc into main Mar 20, 2024
32 checks passed
@bharath-123 bharath-123 deleted the bharath/executor-creates-handles branch March 20, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
composer pertaining to composer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants